/*
CREDITS:
Sprites - Marty Kirra
Pickup - WildWeasel

Up - Mashup, part by Croteam (Serious Sam:SE)
Fire - Croteam (Serious Sam 2)
Add Fire - It's a mashup, sigh... but I think part is by Valve (Half-Life 2)
Holster - Raven (Wolfenstein 3)
*/

ACTOR LeviathanPickup : CustomInventory 24516 //Pickup
{
	//$Category Weapons
	//$Title Leviathan
	//$Sprite LEVGX0
	Inventory.PickupSound "misc/w_pkup"
	Inventory.PickupMessage "You got the ''Leviathan'' handcannon! God bless the Marty for this thing! (3)"
	Scale 0.8
	//+WEAPONSPAWN
	States
	{
		Spawn:
		LEVG X -1
		Stop
		Pickup:
		TNT1 A 0 A_JumpIfInventory("LeviathanPickupCounter",2,"CheckAmmo")
		Goto GiveItNevertheless
		CheckAmmo:
		TNT1 A 0 A_JumpIfInventory("ErasusAmmo",0,"Bailure")
		GiveItNevertheless:
		TNT1 A 0 A_GiveInventory("Leviathan")
		TNT1 A 0 A_GiveInventory("LeviathanPickupCounter",1)
		Stop
		Bailure:
		LEVG X 1
		Fail
	}
}

actor Leviathan : DoomWeapon
{
  Inventory.PickupSound "misc/w_pkup"
  inventory.pickupmessage "You got the ''Leviathan'' handcannon! Because sometimes two barrels simply don't do the laundry. I mean, justice. (3)"
  Obituary "%k did the laundr... I mean, killed %o. With a towel!...\noh come on, there is no freaking bathing reference in the freaking beast name! Come on... okay, I get it.\nIt emerges from the water. Nice one, all hail the master of witty puns."
  Weapon.UpSound "Weapons/LeviathanUp"
  Weapon.SelectionOrder 5
  Weapon.AmmoType "ErasusAmmo"
  Weapon.AmmoGive 10
  Weapon.AmmoUse 3
  Weapon.Kickback 35
  Weapon.SlotNumber 6
  Weapon.BobStyle InverseSmooth
  Weapon.BobSpeed 1.4
  Weapon.BobRangeY 0.6
  Weapon.BobRangeX 1.4
  +NOALERT
  Scale 0.8
  states
  {
  Spawn:
   LEVG X -1
   stop
  Ready:
   LEVG A 0 A_JumpIfInventory("LeviathanPickupCounter",2,"DualReady")
   LEVG A 0 A_JumpIfInventory("LeviathanAltCounter",1,"SightReady")
   LEVG A 1 A_WeaponReady(WRF_ALLOWZOOM)
   Loop
  Select:
   LEVG A 0 A_JumpIfInventory("LeviathanPickupCounter",2,"DualSelect")
   LEVG A 0 A_Raise
   LEVG A 1 A_Raise
   loop
  Deselect:
   LEVG A 0 A_ZoomFactor(1)
   LEVG A 0 A_JumpIfInventory("LeviathanPickupCounter",2,"DualDeselect")
   LEVG A 0 A_JumpIfInventory("LeviathanAltCounter",1,"SightDeselect")
   LEVG A 0 A_Lower
   LEVG A 1 A_Lower
   loop
  Fire:
   LEVG A 0 A_JumpIfInventory("LeviathanAltCounter",1,"SightFire")
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_ChangeVelocity (Cos(Pitch) * -7, 0, Sin(Pitch) * 7,CVF_RELATIVE)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(3,3,0,32,"none")
   TNT1 A 0 A_SetAngle(Angle-1.5)
   TNT1 A 0 A_SetPitch(Pitch-1.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.5)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadFire")
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 18, "ErasusPuff")
   Goto CthulhuEatsVirgins
 QuadFire:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.7)
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 36, "QuadPuff")
 CthulhuEatsVirgins:
   LEVF A 1 bright A_ZoomFactor(0.97)
   LEVF B 1 bright A_ZoomFactor(0.98)
   LEVF C 1 A_ZoomFactor(0.985)
   LEVF D 1 A_ZoomFactor(0.99)
   LEVF E 1 A_ZoomFactor(0.995)
   LEVF F 1 A_ZoomFactor(1)
   LEVF GHIJKLM 1
   LEVG A 1
   goto Ready

 Zoom:
   LEVG A 0 A_JumpIfInventory("LeviathanPickupCounter",2,"DualSight")
   LEVG A 0 A_JumpIfInventory("LeviathanAltCounter",1,"DeSight")
   LEVG A 0 A_GiveInventory("LeviathanAltCounter",1)

   LEIS A 0 A_PlaySound("Weapons/LeviathanHolster")
   LEIS A 0 ACS_NamedExecute("Slowride",0,125,0,0)
   LEIS A 1 A_ZoomFactor(1.1)
   LEIS B 1 A_ZoomFactor(1.125)
   LEIS C 1 A_ZoomFactor(1.15)
   LEIS D 1 A_ZoomFactor(1.2)
   LEIS E 1 A_ZoomFactor(1.3)
   LEIS F 1 A_ZoomFactor(1.4)
   LEIG A 1 A_ZoomFactor(1.5)
   Goto SightReady
 SightReady:
   LEIG A 1 A_WeaponReady(WRF_ALLOWZOOM)
   Loop
 DeSight:
   LEIG A 0 A_PlaySound("Weapons/LeviathanHolster")
   LEIG A 0 A_TakeInventory("LeviathanAltCounter",1)
   LEIG A 0 ACS_NamedExecute("Slowride",0,100,0,0)
   LEIG A 1 A_ZoomFactor(1.5)
   LEIS F 1 A_ZoomFactor(1.4)
   LEIS E 1 A_ZoomFactor(1.3)
   LEIS D 1 A_ZoomFactor(1.2)
   LEIS C 1 A_ZoomFactor(1.15)
   LEIS B 1 A_ZoomFactor(1.125)
   LEIS A 1 A_ZoomFactor(1)
   Goto Ready
 SightDeselect:
   LEIS A 0 A_PlaySound("Weapons/LeviathanHolster")
   LEIS A 0 A_TakeInventory("LeviathanAltCounter",1)
   LEIS A 0 ACS_NamedExecute("Slowride",0,100,0,0)
   LEIS A 1 A_ZoomFactor(1.5)
   LEIS F 1 A_ZoomFactor(1.4)
   LEIS E 1 A_ZoomFactor(1.3)
   LEIS D 1 A_ZoomFactor(1.2)
   LEIS C 1 A_ZoomFactor(1.15)
   LEIS B 1 A_ZoomFactor(1.125)
   LEIS A 1 A_ZoomFactor(1)
   Goto Deselect
 SightFire:
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_Recoil(3)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(4,3,0,32,"none")
   TNT1 A 0 A_SetPitch(Pitch-0.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0) 
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.55)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadSightFire")
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 18, "ErasusPuff")
   Goto PotatoShushKebabMixer
 QuadSightFire:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.75)
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 36, "QuadPuff")
 PotatoShushKebabMixer:
   LEIF A 1 bright A_ZoomFactor(1.46)
   LEIF B 1 bright A_ZoomFactor(1.47)
   LEIF C 1 A_ZoomFactor(1.48)
   LEIF D 1 A_ZoomFactor(1.49)
   LEIF E 1 A_ZoomFactor(1.5)
   LEIF F 1
   LEIF G 1
   LEIG A 5
   goto Ready

  DualReady:
   TNT1 A 0 A_GiveInventory("SynthFireActive",1)
   TNT1 A 0 ACS_NamedExecuteAlways("SynthLeft")
   TNT1 A 0 ACS_NamedExecuteAlways("SynthRight")
   TNT1 A 0 A_GunFlash("Flash",GFF_NOEXTCHANGE)
   Goto RIdle
  DualSelect:
   LV3G A 0 A_Raise
   LV3G A 1 A_Raise
   loop
  DualDeselect:
   TNT1 A 0 A_TakeInventory("SynthFireActive",1)
   TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
   TNT1 A 0 A_TakeInventory("SynthFireRight",1)
   TNT1 A 0 A_GunFlash("Nullify",GFF_NOEXTCHANGE)
   LV3G A 0 A_JumpIfInventory("LeviathanAltCounter",1,"DualSightDeselect")
   LV3G A 0 A_Lower
   LV3G A 1 A_Lower
   loop
  RIdle:
   LVRG A 0 A_JumpIfInventory("SynthFireRight",1,"FireRight")
   LVRG A 1 A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM)
   Loop
  FireRight:
   TNT1 A 0 A_JumpIfInventory("ErasusAmmo",3,1)
   Goto NopeRight
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_ChangeVelocity (Cos(Pitch) * -7, 0, Sin(Pitch) * 7,CVF_RELATIVE)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(3,3,0,32,"none")
   TNT1 A 0 A_SetAngle(Angle-1.5)
   TNT1 A 0 A_SetPitch(Pitch-1.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.5)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadFireRight")
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 18, "ErasusPuff")
   Goto MictantecutliEatsDeadPeople
 QuadFireRight:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.7)
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 36, "QuadPuff")
 MictantecutliEatsDeadPeople:
   LEVR A 1 bright A_ZoomFactor(0.97)
   LEVR B 1 bright A_ZoomFactor(0.98)
   LEVR C 1 A_ZoomFactor(0.985)
   LEVR D 1 A_ZoomFactor(0.99)
   LEVR E 1 A_ZoomFactor(0.995)
   LEVR F 1 A_ZoomFactor(1)
   LEVR GHIJKLM 1
   LVRG A 1
   Goto RIdle
 NopeRight:
   TNT1 A 0 A_PlaySound("Weapons/LeviathanNope",1,0.9)
   LEVR MLKJJKLM 1
   LVRG A 8
   Goto RIdle
  Nullify:
   TNT1 A 0
   Stop
  Flash:
   TNT1 A 0 A_Light0
  LIdle:
   LVLG A 1 A_JumpIfInventory("SynthFireLeft",1,"FireLeft")
   Loop
  FireLeft:
   TNT1 A 0 A_JumpIfInventory("ErasusAmmo",3,1)
   Goto NopeLeft
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_ChangeVelocity (Cos(Pitch) * -7, 0, Sin(Pitch) * 7,CVF_RELATIVE)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(3,3,0,32,"none")
   TNT1 A 0 A_SetAngle(Angle+1.5)
   TNT1 A 0 A_SetPitch(Pitch-1.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.5)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadFireLeft")
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 18, "ErasusPuff")
   Goto TezcatlipocaLollery
 QuadFireLeft:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.7)
   TNT1 A 0 A_FireBullets(17.5, 3.75, 45, 36, "QuadPuff")
 TezcatlipocaLollery:
   LEVL A 1 bright A_ZoomFactor(0.97)
   LEVL B 1 bright A_ZoomFactor(0.98)
   LEVL C 1 A_ZoomFactor(0.985)
   LEVL D 1 A_ZoomFactor(0.99)
   LEVL E 1 A_ZoomFactor(0.995)
   LEVL F 1 A_ZoomFactor(1)
   LEVL GHIJKLM 1
   LVLG A 1
   Goto LIdle
 NopeLeft:
   TNT1 A 0 A_PlaySound("Weapons/LeviathanNope",1,0.9)
   LEVL MLKJJKLM 1
   LVLG A 8
   Goto LIdle
   
 DualSight:
   TNT1 A 0 A_TakeInventory("SynthFireActive",1)
   TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
   TNT1 A 0 A_TakeInventory("SynthFireRight",1)
   TNT1 A 0 A_GunFlash("Nullify",GFF_NOEXTCHANGE)
   LI2S A 0 A_PlaySound("Weapons/LeviathanHolster")
   LI2S A 0 A_JumpIfInventory("LeviathanAltCounter",1,"DualDeSight")
   LI2S A 0 A_GiveInventory("LeviathanAltCounter",1)
   LI2S A 0 ACS_NamedExecute("Slowride",0,125,0,0)
   LI2S M 1 A_ZoomFactor(1.025)
   LI2S L 1 A_ZoomFactor(1.05)
   LI2S K 1 A_ZoomFactor(1.075)
   LI2S J 1 A_ZoomFactor(1.1)
   LI2S I 1 A_ZoomFactor(1.15)
   LI2S H 1 A_ZoomFactor(1.2)
   LI2S G 1 A_ZoomFactor(1.25)
   LI2S F 1 A_ZoomFactor(1.3)
   LI2S E 1 A_ZoomFactor(1.35)
   LI2S D 1 A_ZoomFactor(1.4)
   LI2S C 1 A_ZoomFactor(1.45)
   LI2S B 1 A_ZoomFactor(1.475)
   LI2S A 1 A_ZoomFactor(1.5)
   Goto DualSightReady
 DualSightReady:
   TNT1 A 0 A_GiveInventory("SynthFireActive",1)
   TNT1 A 0 ACS_NamedExecuteAlways("SynthLeft")
   TNT1 A 0 ACS_NamedExecuteAlways("SynthRight")
   TNT1 A 0 A_GunFlash("Flash2",GFF_NOEXTCHANGE)
   Goto RIdleSight
 DualDeSight:
   LI2S A 0 A_TakeInventory("LeviathanAltCounter",1)
   LI2S A 0 ACS_NamedExecute("Slowride",0,100,0,0)
   LI2S A 1 A_ZoomFactor(1.5)
   LI2S B 1 A_ZoomFactor(1.475)
   LI2S C 1 A_ZoomFactor(1.45)
   LI2S D 1 A_ZoomFactor(1.4)
   LI2S E 1 A_ZoomFactor(1.35)
   LI2S F 1 A_ZoomFactor(1.3)
   LI2S G 1 A_ZoomFactor(1.25)
   LI2S H 1 A_ZoomFactor(1.2)
   LI2S I 1 A_ZoomFactor(1.15)
   LI2S J 1 A_ZoomFactor(1.1)
   LI2S K 1 A_ZoomFactor(1.075)
   LI2S L 1 A_ZoomFactor(1.05)
   LI2S M 1 A_ZoomFactor(1.025)
   LV3G A 1 A_ZoomFactor(1)
   Goto DualReady
 DualSightDeselect:
   LI2S A 0 A_PlaySound("Weapons/LeviathanHolster")
   LI2S A 0 A_TakeInventory("LeviathanAltCounter",1)
   LI2S A 0 ACS_NamedExecute("Slowride",0,100,0,0)
   LI2S A 1 A_ZoomFactor(1.5)
   LI2S B 1 A_ZoomFactor(1.475)
   LI2S C 1 A_ZoomFactor(1.45)
   LI2S D 1 A_ZoomFactor(1.4)
   LI2S E 1 A_ZoomFactor(1.35)
   LI2S F 1 A_ZoomFactor(1.3)
   LI2S G 1 A_ZoomFactor(1.25)
   LI2S H 1 A_ZoomFactor(1.2)
   LI2S I 1 A_ZoomFactor(1.15)
   LI2S J 1 A_ZoomFactor(1.1)
   LI2S K 1 A_ZoomFactor(1.075)
   LI2S L 1 A_ZoomFactor(1.05)
   LI2S M 1 A_ZoomFactor(1.025)
   LV3G A 1 A_ZoomFactor(1)
   Goto DualDeselect
  RIdleSight:
   RI2G A 0 A_JumpIfInventory("SynthFireRight",1,"SightFireRight")
   RI2G A 1 A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM)
   Loop
  SightFireRight:
   TNT1 A 0 A_JumpIfInventory("ErasusAmmo",3,1)
   Goto NopeRightSight
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_Recoil(3)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(4,3,0,32,"none")
   TNT1 A 0 A_SetAngle(Angle-0.5)
   TNT1 A 0 A_SetPitch(Pitch-0.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.55)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadSightFireRight")
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 18, "ErasusPuff")
   Goto WololoYouAreRed
 QuadSightFireRight:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.75)
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 36, "QuadPuff")
 WololoYouAreRed:
   LIRF A 1 bright A_ZoomFactor(1.46)
   LIRF B 1 bright A_ZoomFactor(1.47)
   LIRF C 1 A_ZoomFactor(1.48)
   LIRF D 1 A_ZoomFactor(1.49)
   LIRF E 1 A_ZoomFactor(1.5)
   LIRF F 1
   RI2G A 5
   Goto RIdleSight
 NopeRightSight:
   TNT1 A 0 A_PlaySound("Weapons/LeviathanNope",5,0.9)
   LIRF FEDDEF 1
   RI2G A 6
   Goto RIdleSight
   
  Flash2:
   TNT1 A 0 A_Light0
  LIdleSight:
   LI2G A 1 A_JumpIfInventory("SynthFireLeft",1,"SightFireLeft")
   Loop
 SightFireLeft:
   TNT1 A 0 A_JumpIfInventory("ErasusAmmo",3,1)
   Goto NopeLeftSight
   TNT1 A 0 A_AlertMonsters
   TNT1 A 0 A_Recoil(3)
   TNT1 A 0 A_GiveInventory("ErasusCasing",3)
   TNT1 A 0 A_Quake(4,3,0,32,"none")
   TNT1 A 0 A_SetAngle(Angle+0.5)
   TNT1 A 0 A_SetPitch(Pitch-0.5)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanFire",1,1.0)
   TNT1 A 0 A_PlaySound("Weapons/LeviathanAddFire",5,0.55)
   TNT1 A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadSightFireLeft")
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 18, "ErasusPuff")
   Goto WololoYouAreBlue
 QuadSightFireLeft:
   TNT1 A 0 A_SetBlend("Blue",0.075,16)
   TNT1 A 0 A_PlaySound("Weapons/QuadShot",6,0.75)
   TNT1 A 0 A_FireBullets(4.5, 1.15, 45, 36, "QuadPuff")
 WololoYouAreBlue:
   LILF A 1 bright A_ZoomFactor(1.46)
   LILF B 1 bright A_ZoomFactor(1.47)
   LILF C 1 A_ZoomFactor(1.48)
   LILF D 1 A_ZoomFactor(1.49)
   LILF E 1 A_ZoomFactor(1.5)
   LILF F 1
   LI2G A 5
   goto LIdleSight
 NopeLeftSight:
   TNT1 A 0 A_PlaySound("Weapons/LeviathanNope",5,0.9)
   LILF FEDDEF 1
   LI2G A 6
   Goto LIdleSight
  }
}

actor LeviathanPickupCounter : Inventory
{
  inventory.maxamount 2
  inventory.icon "TNT1A0"
}

actor LeviathanAltCounter : Inventory
{
  inventory.maxamount 1
}
